import os

cls = lambda: os.system("cls")

from mido import MidiFile

from rich import print as prt

import time

from MineMusicVisualizer.main import gen_dropping_notes_screen, gen_colour_map
from Musicreater import MusicSequence

cls()

file_path = r"C:\Eilles\程设\音创\#master\遠い空へ.mid"

msq = MusicSequence.from_mido(MidiFile(file_path, clip=True), "Test")

# print("\033[", flush=True)
colourmap = gen_colour_map(list(msq.note_count_per_instrument.keys()))

prt(colourmap)

input("回车开始")

print("\033[2J", flush=True)

for line in gen_dropping_notes_screen(msq, colourmap, 100, 25):
    k = time.time()
    # cls()
    print("\033[H", flush=True)
    print(line, flush=True)

    time.sleep(1 / 22 - (time.time() - k))
